package com.ht.baselibs.ui.holder;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ht.baselibs.R;
import com.ht.baselibs.bean.SelectItemBean;
import com.ht.baselibs.ui.base.BaseViewHolder;

/**
 * Created by huangtao on 16/9/18.
 */
public class SelectItemViewHolder extends BaseViewHolder<SelectItemBean> {
    private final int position;

    private TextView tv_list_select_item_name;
    private ImageView iv_list_select_item;
    private View view_list_select_item_name_line_top;
    private TextView tv_list_select_item_text_value;

    public SelectItemViewHolder(int position) {
        super(R.layout.list_select_item);
        this.position = position;
    }

    @Override
    protected void initView() {
        tv_list_select_item_name = findViewById(R.id.tv_list_select_item_name);
        iv_list_select_item = findViewById(R.id.iv_list_select_item);
        view_list_select_item_name_line_top = findViewById(R.id.view_list_select_item_name_line_top);
        tv_list_select_item_text_value = findViewById(R.id.tv_list_select_item_text_value);
    }

    @Override
    protected void refreshView(SelectItemBean selectItemBean) {
        tv_list_select_item_name.setText(selectItemBean.shortName);

        if (selectItemBean.textValue != null){
            iv_list_select_item.setVisibility(View.GONE);
            tv_list_select_item_text_value.setVisibility(View.VISIBLE);
            tv_list_select_item_text_value.setText(selectItemBean.textValue);
        } else {
            tv_list_select_item_text_value.setVisibility(View.GONE);
            if (selectItemBean.isSelect){
                iv_list_select_item.setVisibility(View.VISIBLE);
            }else{
                iv_list_select_item.setVisibility(View.GONE);
            }
        }

        if (position == 0){
            view_list_select_item_name_line_top.setVisibility(View.VISIBLE);
        }else{
            view_list_select_item_name_line_top.setVisibility(View.GONE);
        }
    }
}
